package com.java.day03;

import java.util.Scanner;

/**
 * 循环录入5个人的成绩，求最大成绩、最小成绩、平均成绩
 * */
public class practise01 {
    public static void main(String[] args) {
        //成绩
        double grade;
        //最大值
        double max=0;
        //最小值
        double min=0;
        //求和
        double sum = 0;


        fiveGrade(max, min, sum);
    }

    private static void fiveGrade(double max, double min, double sum) {//方法
        double grade;
        Scanner scanner = new Scanner(System.in);

        for (int i = 1; i <= 5; i++) {
            System.out.println("请输入第"+i+"位同学的成绩:");
            grade=scanner.nextDouble();
            sum +=grade;
            if(max ==0||grade> max){
                max = grade;
            }
            if(min ==0||grade< min){
                min = grade;
            }
        }
        System.out.println("最大成绩为:"+ max);
        System.out.println("最小成绩为:"+ min);
        System.out.println("平均成绩为:"+(sum /5));
    }


}
